package com.esri.core.renderer;

import com.esri.core.internal.util.d;
import com.esri.core.symbol.Symbol;
import java.io.IOException;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonNode;

/* loaded from: classes.dex */
public class ClassificationDefinition {
    protected String _type;
    private Symbol a;
    private ColorRamp b;

    public ClassificationDefinition() {
    }

    public ClassificationDefinition(JsonNode jsonNode) {
        this._type = jsonNode.findValue("type").getTextValue();
        JsonNode findValue = jsonNode.findValue("baseSymbol");
        JsonNode findValue2 = jsonNode.findValue("colorRamp");
        if (findValue != null) {
            try {
                this.a = d.h(findValue.traverse());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (findValue2 != null) {
            String textValue = findValue2.findValue("type").getTextValue();
            if ("algorithmic".equals(textValue)) {
                this.b = new AlgorithmicColorRamp(findValue2);
            } else if ("multipart".equals(textValue)) {
                this.b = new MultipartColorRamp(findValue2);
            }
        }
    }

    public Symbol getBaseSymbol() {
        return this.a;
    }

    public void setBaseSymbol(Symbol symbol) {
        this.a = symbol;
    }

    public ColorRamp getColorRamp() {
        return this.b;
    }

    public void setColorRamp(ColorRamp colorRamp) {
        this.b = colorRamp;
    }

    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        toJson(a);
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void toJson(JsonGenerator jsonGenerator) throws IOException, JsonGenerationException, Exception {
        jsonGenerator.writeStringField("type", this._type);
        if (this.a != null) {
            jsonGenerator.writeFieldName("baseSymbol");
            jsonGenerator.writeRawValue(this.a.toJson());
        }
        if (this.b != null) {
            jsonGenerator.writeFieldName("colorRamp");
            jsonGenerator.writeRawValue(this.b.toJson());
        }
    }

    public String toString() {
        return "ClassificationDefinition [baseSymbol=" + this.a + ", colorRamp=" + this.b + ", type=" + this._type + "]";
    }
}
